home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / management / VMManagementImpl.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  5.4 KB  |  245 lines

  1. package sun.management;
  2.  
  3. import java.io.IOException;
  4. import java.net.InetAddress;
  5. import java.net.UnknownHostException;
  6. import java.nio.ByteBuffer;
  7. import java.security.AccessController;
  8. import java.util.ArrayList;
  9. import java.util.Collections;
  10. import java.util.List;
  11. import java.util.StringTokenizer;
  12. import sun.management.counter.perf.PerfInstrumentation;
  13. import sun.misc.Perf;
  14. import sun.security.action.GetPropertyAction;
  15.  
  16. class VMManagementImpl implements VMManagement {
  17.    private static String version = getVersion0();
  18.    private static boolean compTimeMonitoringSupport;
  19.    private static boolean threadContentionMonitoringSupport;
  20.    private static boolean currentThreadCpuTimeSupport;
  21.    private static boolean otherThreadCpuTimeSupport;
  22.    private static boolean bootClassPathSupport;
  23.    private static boolean objectMonitorUsageSupport;
  24.    private static boolean synchronizerUsageSupport;
  25.    private List<String> vmArgs = null;
  26.    private List<String> unmodifiableVmArgsList = null;
  27.    private PerfInstrumentation perfInstr = null;
  28.    private boolean noPerfData = false;
  29.  
  30.    private static native String getVersion0();
  31.  
  32.    private static native void initOptionalSupportFields();
  33.  
  34.    public boolean isCompilationTimeMonitoringSupported() {
  35.       return compTimeMonitoringSupport;
  36.    }
  37.  
  38.    public boolean isThreadContentionMonitoringSupported() {
  39.       return threadContentionMonitoringSupport;
  40.    }
  41.  
  42.    public boolean isCurrentThreadCpuTimeSupported() {
  43.       return currentThreadCpuTimeSupport;
  44.    }
  45.  
  46.    public boolean isOtherThreadCpuTimeSupported() {
  47.       return otherThreadCpuTimeSupport;
  48.    }
  49.  
  50.    public boolean isBootClassPathSupported() {
  51.       return bootClassPathSupport;
  52.    }
  53.  
  54.    public boolean isObjectMonitorUsageSupported() {
  55.       return objectMonitorUsageSupport;
  56.    }
  57.  
  58.    public boolean isSynchronizerUsageSupported() {
  59.       return synchronizerUsageSupport;
  60.    }
  61.  
  62.    public native boolean isThreadContentionMonitoringEnabled();
  63.  
  64.    public native boolean isThreadCpuTimeEnabled();
  65.  
  66.    public int getLoadedClassCount() {
  67.       long var1 = this.getTotalClassCount() - this.getUnloadedClassCount();
  68.       return (int)var1;
  69.    }
  70.  
  71.    public native long getTotalClassCount();
  72.  
  73.    public native long getUnloadedClassCount();
  74.  
  75.    public native boolean getVerboseClass();
  76.  
  77.    public native boolean getVerboseGC();
  78.  
  79.    public String getManagementVersion() {
  80.       return version;
  81.    }
  82.  
  83.    public String getVmId() {
  84.       int var1 = this.getProcessId();
  85.       String var2 = "localhost";
  86.  
  87.       try {
  88.          var2 = InetAddress.getLocalHost().getHostName();
  89.       } catch (UnknownHostException var4) {
  90.       }
  91.  
  92.       return var1 + "@" + var2;
  93.    }
  94.  
  95.    private native int getProcessId();
  96.  
  97.    public String getVmName() {
  98.       return System.getProperty("java.vm.name");
  99.    }
  100.  
  101.    public String getVmVendor() {
  102.       return System.getProperty("java.vm.vendor");
  103.    }
  104.  
  105.    public String getVmVersion() {
  106.       return System.getProperty("java.vm.version");
  107.    }
  108.  
  109.    public String getVmSpecName() {
  110.       return System.getProperty("java.vm.specification.name");
  111.    }
  112.  
  113.    public String getVmSpecVendor() {
  114.       return System.getProperty("java.vm.specification.vendor");
  115.    }
  116.  
  117.    public String getVmSpecVersion() {
  118.       return System.getProperty("java.vm.specification.version");
  119.    }
  120.  
  121.    public String getClassPath() {
  122.       return System.getProperty("java.class.path");
  123.    }
  124.  
  125.    public String getLibraryPath() {
  126.       return System.getProperty("java.library.path");
  127.    }
  128.  
  129.    public String getBootClassPath() {
  130.       GetPropertyAction var1 = new GetPropertyAction("sun.boot.class.path");
  131.       String var2 = (String)AccessController.doPrivileged(var1);
  132.       return var2;
  133.    }
  134.  
  135.    public synchronized List<String> getVmArguments() {
  136.       if (this.vmArgs == null) {
  137.          this.vmArgs = new ArrayList();
  138.          String var1 = this.getVmArguments0();
  139.          if (var1 != null) {
  140.             StringTokenizer var2 = new StringTokenizer(var1, " ");
  141.  
  142.             while(var2.hasMoreTokens()) {
  143.                this.vmArgs.add(var2.nextToken());
  144.             }
  145.          }
  146.  
  147.          this.unmodifiableVmArgsList = Collections.unmodifiableList(this.vmArgs);
  148.       }
  149.  
  150.       return this.unmodifiableVmArgsList;
  151.    }
  152.  
  153.    public native String getVmArguments0();
  154.  
  155.    public native long getStartupTime();
  156.  
  157.    public native int getAvailableProcessors();
  158.  
  159.    public String getCompilerName() {
  160.       String var1 = (String)AccessController.doPrivileged(new 1(this));
  161.       return var1;
  162.    }
  163.  
  164.    public native long getTotalCompileTime();
  165.  
  166.    public native long getTotalThreadCount();
  167.  
  168.    public native int getLiveThreadCount();
  169.  
  170.    public native int getPeakThreadCount();
  171.  
  172.    public native int getDaemonThreadCount();
  173.  
  174.    public String getOsName() {
  175.       return System.getProperty("os.name");
  176.    }
  177.  
  178.    public String getOsArch() {
  179.       return System.getProperty("os.arch");
  180.    }
  181.  
  182.    public String getOsVersion() {
  183.       return System.getProperty("os.version");
  184.    }
  185.  
  186.    public native long getSafepointCount();
  187.  
  188.    public native long getTotalSafepointTime();
  189.  
  190.    public native long getSafepointSyncTime();
  191.  
  192.    public native long getTotalApplicationNonStoppedTime();
  193.  
  194.    public native long getLoadedClassSize();
  195.  
  196.    public native long getUnloadedClassSize();
  197.  
  198.    public native long getClassLoadingTime();
  199.  
  200.    public native long getMethodDataSize();
  201.  
  202.    public native long getInitializedClassCount();
  203.  
  204.    public native long getClassInitializationTime();
  205.  
  206.    public native long getClassVerificationTime();
  207.  
  208.    private synchronized PerfInstrumentation getPerfInstrumentation() {
  209.       if (!this.noPerfData && this.perfInstr == null) {
  210.          Perf var1 = (Perf)AccessController.doPrivileged(new Perf.GetPerfAction());
  211.  
  212.          try {
  213.             ByteBuffer var2 = var1.attach(0, "r");
  214.             if (var2.capacity() == 0) {
  215.                this.noPerfData = true;
  216.                return null;
  217.             }
  218.  
  219.             this.perfInstr = new PerfInstrumentation(var2);
  220.          } catch (IllegalArgumentException var3) {
  221.             this.noPerfData = true;
  222.          } catch (IOException var4) {
  223.             throw new InternalError(var4.getMessage());
  224.          }
  225.  
  226.          return this.perfInstr;
  227.       } else {
  228.          return this.perfInstr;
  229.       }
  230.    }
  231.  
  232.    public List getInternalCounters(String var1) {
  233.       PerfInstrumentation var2 = this.getPerfInstrumentation();
  234.       return var2 != null ? var2.findByPattern(var1) : Collections.EMPTY_LIST;
  235.    }
  236.  
  237.    static {
  238.       if (version == null) {
  239.          throw new InternalError("Invalid Management Version");
  240.       } else {
  241.          initOptionalSupportFields();
  242.       }
  243.    }
  244. }
  245.